// @FileName  :2024_T1.c
// @Time      :2024/5/10 23:11
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>
# include <ctype.h>

typedef struct node {
    int st, sz, ed;
    struct node *nxt;
} node;
int st, sz, ed, cnt;

int main() {
    setbuf(stdout, NULL);
    node *head = (node *) malloc(sizeof(node)), *p;
    head->nxt = NULL;
    head->ed = 0;
    while (scanf("%d%d", &sz, &st)) {
        if (st == -1 && sz == -1)break;
        ed = sz + st;
        p = head;
        while (p != NULL) {
            if (p->st == ed) {//合并p头
                p->st = st, p->sz += sz;
                break;
            } else if (p->ed == st) {
                p->sz += sz, p->ed = ed;
                break;
            } else if (p->ed < st) {
                if (p->nxt == NULL || p->nxt->st > ed) {
                    node *neo = (node *) malloc(sizeof(node));
                    neo->st = st, neo->sz = sz, neo->ed = st + sz;
                    neo->nxt = p->nxt;
                    p->nxt = neo;
                    break;
                } else
                    p = p->nxt, cnt++;
            }
//            else
//                p = p->nxt, cnt++;
        }
    }
    printf("%d\n", cnt);
    p = head->nxt;
    while (p != NULL) {
        printf("%d %d\n", p->st, p->sz);
        p = p->nxt;
    }
}

/*
400 4000
800 6000
600 8000
624 10168
828 12004
808 8808
800 2000
328 7248
-1 -1


400 4000
800 6000
600 8000
624 10168
828 12004
808 8808
800 2000
328 7248
240 6800
208 8600
-1 -1
 */